home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dc1 / defs.h < prev    next >
C/C++ Source or Header  |  1997-09-09  |  3KB  |  110 lines

  1.  
  2. /*
  3.  *  DC1/DEFS.H
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  *
  9.  */
  10.  
  11. typedef unsigned char    ubyte;
  12. typedef unsigned short    uword;
  13. #ifndef NO_ULONG
  14. typedef unsigned long    ulong;
  15. #endif
  16.  
  17. #include <stdarg.h>            /* standard includes     */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <lib/version.h>
  22. #include "sym.h"            /* local includes    */
  23. #include "tokens.h"
  24. #include "machine.h"
  25. #include "stmt.h"
  26. #include "var.h"
  27. #include "types.h"
  28. #include "error.h"
  29.  
  30. /*
  31.  *  Subtle slow down for freeware release
  32.  */
  33.  
  34. #ifdef _DCC
  35. #if !defined(REGISTERED) && !defined(COMMERCIAL)
  36. #undef putc
  37. #define putc(c,fi) (((fi)->sd_WLeft <= 0) ? fputc((c),(fi)) : \
  38.      (((--(fi)->sd_WLeft, ((*(fi)->sd_WPtr++ = (c))) == '\n')) ? (fflush(fi), '\n') : ((fi)->sd_WPtr)[-1]))
  39. #endif
  40. #endif
  41.  
  42. typedef struct LexFileNode {
  43.     struct LexFileNode *lf_Next;
  44.     FILE    *lf_Fi;        /*    file handle, keeps cache valid              */
  45.     char    *lf_Buf;        /*    buffer, offset negative!! invalid < BaseIndex */
  46.     char    *lf_FileName;
  47. #ifdef MINIDICE2
  48.     uword   lf_BaseIndex;
  49.     uword   lf_Index;        /*    current index    */
  50.     uword   lf_Size;        /*    size of file    */
  51. #else
  52.     long    lf_BaseIndex;
  53.     long    lf_Index;        /*    current index    */
  54.     long    lf_Size;        /*    size of file    */
  55. #endif
  56. } LexFileNode;
  57.  
  58. #define MINIMAXPROCS    5
  59.  
  60.  
  61. #define Prototype   extern
  62. #define Local        static
  63.  
  64. #ifndef AMIGA
  65.  
  66. #define __stkargs
  67. #include <suplib/string.h>
  68. #include <suplib/memory.h>
  69.  
  70. #endif
  71.  
  72. #ifdef DEBUG
  73. #define dbprintf(x) if (DDebug) printf x
  74. #else
  75. #define dbprintf(x)
  76. #endif
  77.  
  78. #define CHUNKSIZE   8192
  79.  
  80. #include "protos.h"
  81.  
  82. #define AllocStructure(type)  ((type *)zalloc(sizeof(type)))
  83. #define AllocTmpStructure(type)  ((type *)talloc(sizeof(type)))
  84. #define arysize(ary)    (sizeof(ary)/sizeof((ary)[0]))
  85.  
  86. /*
  87.  *  Call for gen*.c
  88.  */
  89.  
  90. #define CallCenter() ((*exp->ex_Func)(&exp))
  91. #define CallLeft()   ((*exp->ex_ExpL->ex_Func)(&exp->ex_ExpL))
  92. #define CallRight()  ((*exp->ex_ExpR->ex_Func)(&exp->ex_ExpR))
  93. #define EnsureReturnStorageLeft()   { if ((exp->ex_ExpR->ex_Flags & EF_CALL) || ((exp->ex_Flags & EF_ASSEQ) && (exp->ex_Flags & EF_CALL))) UnscratchStorage(exp->ex_ExpL); }
  94. #define EnsureReturnStorageRight()  { if (exp->ex_ExpL->ex_Flags & EF_CALL) UnscratchStorage(exp->ex_ExpR); }
  95.  
  96. #define SOUTSIDE    1    /*  outside procedures            */
  97. #define SARG        2    /*  declaring procedural arguments  */
  98. #define SINSIDE     3    /*  inside procedure            */
  99.  
  100. #define Assert(cond)    if (!(cond)) _Assert(_SrcFile, __LINE__)
  101.  
  102. #ifdef __BASE_FILE__
  103. static const char *_SrcFile = __BASE_FILE__;
  104. #else
  105. static const char *_SrcFile = "unknown.c";
  106. #endif
  107.  
  108. #define GetToken()  ((LexDispatch[(ubyte)LFBase->lf_Buf[LFBase->lf_Index]])())
  109.  
  110.